Date.prototype.format = function(format) //author: meizz 
{
	var o = {
		"M+": this.getMonth() + 1,
		//month 
		"d+": this.getDate(),
		//day 
		"h+": this.getHours(),
		//hour 
		"m+": this.getMinutes(),
		//minute 
		"s+": this.getSeconds(),
		//second 
		"q+": Math.floor((this.getMonth() + 3) / 3),
		//quarter 
		"S": this.getMilliseconds() //millisecond 
	}
	if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	for (var k in o) if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
	return format;
}
function AddParam(str,paramName,paramValue)
{
    if(str.charAt(str.length - 1) != '?')
    {
        str += '&';
    }
    str += paramName;
    str += '=';
    str += paramValue;
    return str;
    
}
function arrayexist(arr, value) {
	for (var key in arr) {
		if (arr[key] == value) {
			return true;
		}
	}
	return false;
}
String.prototype.format = function(args) {
    var result = this;
    if (arguments.length > 0) {    
        if (arguments.length == 1 && typeof (args) == "object") {
            for (var key in args) {
                if(args[key]!=undefined){
                    var reg = new RegExp("({" + key + "})", "g");
                    result = result.replace(reg, args[key]);
                }
            }
        }
        else {
            for (var i = 0; i < arguments.length; i++) {
                if (arguments[i] != undefined) {
                    var reg = new RegExp("({[" + i + "]})", "g");
                    result = result.replace(reg, arguments[i]);
                }
            }
        }
    }
    return result;
}

function StrToDate(str)
{
   // console.log(str);
    var yearend = str.search("-");
    var year = str.substring(0,yearend);
    str = str.substring(yearend + 1);
    //console.log(year);
    var monthend = str.search("-");
    var month = str.substring(0,monthend);
    str = str.substring(monthend + 1);
    //console.log(month);
    var dayend = str.search(" ");
    var day = str.substring(0,monthend);
    //console.log(day);
    return new Date(year + "/" + month + "/" + day);
}